home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
System source
/
Frontend
< prev
next >
Wrap
Text File
|
1994-06-24
|
8KB
|
259 lines
\ frontEnd - menus and handlers for Yerk menu bar
\ 12/20/84 cbd Version 1
\ 7/05/86 cdn Added HFS references
\ 7/09/86 cdn Expanded Util & Yerk menus; added .ok
\ 8/10/86 cdn Added savefW, restfW, enfW, disfW
\ 8/31/88 rfl made parmstr object of string; added show: fwind in yerk
\ 10/04/88 rfl brought back old npath
\ 10/03/90 rfl added 0 ?event drop to get window out in front in mf
\ 3/23/91 rfl don't check for hfs ..just assume
\ 5/10/91 rfl editor name now at string resource id 99
\ 6/09/91 rfl modified editor name...in rsrc, make sure it starts with two zeros
\ 11/17/91 rfl added 7.0.1 fix readFP before saving image
\ 4/24/92 rfl added closeAll for development
\ 5/14/92 rfl removed savefw
\ 10/14/92 rfl sysedits now supports key: window; cut,copy,paste for the front window
\ 1/02/93 rfl menus now in resources. Old menu module still available, though.
\ 5/03/93 rfl added new tool1 for testing
\ 5/20/93 rfl added saver to save currently named document in same folder as original
Decimal
\ mark the Yerk menubar layer for forgets
: FrontEnd ;
create inLine $ 4ed4 w, \ next, \ for inline trap calls jmp (a4)
from tool1 import{ asmcall1 call1 global1 } 2 immediates
Create (flush) popD0 " FlushEvents" asmCall next,
Create (post) popD0 popA0 " PostEvent" asmCall next,
: .ok 8 (flush) 3 13 (post) ;
\ ============== Menu handlers =================
\ define the menus for the Yerk menu bar
5 menu FileMen
8 menu EditMen
9 menu UtilMen
10 menu YerkMen
BasicStr imageName
string parmStr
\ get file from stdFile and load it as source
: stdLoad
new: loadFile
txType 1 stdGet: topFile
draw: fWind
IF interpret: topFile .ok THEN
remove: loadFile ;
: readFP " fpInit" sFind
IF 2drop 5 'type CODE (getres) dup >ptr 'f> rot 0 swap call SizeResource cmove
THEN ;
\ Resave current dictionary
: doSave .cur readFP
get: imageName name: fFcb (save)
curs -curs cr ." Saved: " print: imageName cr
-> curs .ok ;
\ save via stdFile
: stdSave .cur
" Save Dictionary As:" get: imageName str255 -base count
stdPut: fFcb
draw: fWind
IF readFP (save)
getVref: ffcb finfo 4+ w! \ save vref in finfo area
getName: fFcb 2dup put: imageName title: fWind
curs -curs cr ." Saved: " print: imageName cr
-> curs .ok
THEN ;
\ Save current document in same directory as initial document, or the
\ last stdSave'd document...take name from
\ the fwind (which should be the last stdSave'd document)
: Saver readFP
get: imageName name: fFcb finfo 4+ w@ setVref: fFcb (save)
." Saved: " print: imageName cr ;
\ Select and print a text file
: Print
new: loadFile
txType 1 stdGet: topFile
draw: fWind
IF qPrint THEN
remove: loadfile ;
\ ============== Edit Menu =================
\ scrap support
Var theOffset
: getScrap
0 handle: parmStr txType abs: theOffset
call GetScrap ;
\ get next char from the scrap
: scrapKey
next: parmStr 0=
IF rekey 13 THEN ; \ simulate a terminal cr
\ interpret from the scrap
: xDoit
getScrap 0>
IF 0 moveTo: parmStr 'c scrapKey -> keyVec
THEN sp! mp! quit ;
: frontWind 0 call frontwindow -base ;
\ editing commands pass thru to desk accessories
: sysEd >R word0 R> makeInt call SystemEdit word0 ;
: sysCut 2 sysEd not IF cut: [ frontWind ] THEN ;
: sysCopy 3 sysEd not IF copy: [ frontWind ] THEN ;
\ pastes only into the fwind...
: sysPaste { \ theWInd -- } 4 sysEd not
IF frontWind -> theWind
theWind fwind =
IF xDoit
ELSE paste: theWind
THEN
THEN ;
: sysClear 5 sysEd not IF clear: [ frontWind ] THEN ;
\ this string holds the name of the McSink desk accessory
: edName 99 getString ; \ leading null char
: doEdit savePort word0 edName str255 call OpenDeskAcc word0 drop restPort ;
\ ============== Util Menu =================
\ call words from utility module
: doWords .cur
curs -curs words -> curs .ok ;
\ start the object list utility via its input dialog
: doOlist
" List objects of class:" doInDlg
IF over +base over >uc objList .ok THEN ;
\ start the object list with a word in the stream
: do' @word count objList ;
\ run the class lister
: doClist .classes .ok ;
\ start the decompile utility via its input dialog
: doDe
" Enter word to decompile:" doDeDlg
IF tib 128 erase 0 -> in \ simulate terminal input from dialog text
tib swap cMove de' .ok
THEN ;
\ start the grep utility via its input dialog
: doGrep
" Enter string for search:" doGrDlg
IF (grep) .ok THEN ;
\ ============== Yerk Menu =================
\ ( item# b -- ) check item if boolean is true
: chkYerk
IF check: yerkMen
ELSE unCheck: yerkMen
THEN ;
0 value prEcho
0 value LEcho
: ?yerkFlgs 3 LEcho chkYerk 2 dEcho chkYerk 1 prEcho chkYerk ;
\ toggle echo to printer
: pEcho
precho 1 xor -> prEcho prEcho
IF +print
ELSE -print dispose> printMod
THEN ?yerkFlgs ;
\ toggle echo during loads
: ldEcho decho 1 xor -> decho ?yerkFlgs ;
: logging LEcho 1 xor -> LEcho LEcho
IF +file
ELSE -file dispose> logMod
THEN ?yerkflgs ;
\ print path list
: .path path IF cr print: path ELSE ." No paths defined." THEN .ok ;
\ ( -- maxBlk ) Call register-based toolbox routine
create maxmem
" MaxMem" asmCall
pushD0
next,
\ print room remaining in heap, dictionary
: .room cr maxmem \ compression first
." Room in Dictionary: " room 6 .r cr
." Total Heap (no purge): " free 6 .r cr
." Largest Block (purge): " 6 .r cr .ok ;
: doMlist .mods .ok ;
\ note that doSave has been replaced with saver
2 'cfas about null 1 put: appleMen
5 'cfas stdLoad Saver stdSave Print bye 2 put: fileMen
8 'cfas null null sysCut sysCopy sysPaste sysClear null doEdit 3 put: editMen
9 'cfas doWords doOlist doClist hier exam doDe doGrep null install 4 put: utilMen
10 'cfas pEcho ldEcho logging null .path .room doMlist purge null null 5 put: yerkMen
: nmenu applemen fileMen editMen utilMen yerkMen 5 init: menubar ;
\ ============== Non-Menu related words =================
\ Set the maximum dictionary size that Yerk will allow
\ on a large memory Mac. This is done so that on a large system, more heap
\ will be available for modules, etc. than the amount set for a small
\ machine (~22K). The heap is given whatever is left over from the maximum
\ dictionary size, down to a minimum of the value set in Install.
\ You should do a Save using Install after setting this value to save the
\ Yerk nucleus file to disk.
\ ( max-bytes -- )
: maxDict msize ! ;
\ disable/enable actions for fWind
: disfW
1 disable: FileMen 2 disable: FileMen 3 disable: FileMen
0 disable: UtilMen 0 disable: YerkMen ;
: enfW
1 enable: FileMen 2 enable: FileMen 3 enable: FileMen
0 enable: UtilMen 0 enable: YerkMen ;
\ close all windows except for the fwind
: closeAll { \ theWindow -- } 0 call frontWindow
BEGIN -base -> theWindow
theWindow $ 90 + @ \ get next window in list
theWindow fwind <> \ don't close fwind
IF close: theWindow THEN dup 0= \ continue until no more windows
UNTIL drop set: fwind ;
: nPath " ::Yerk folder:nPath.txt" getPtxt ;
\ system startup word
: yerk
sysInit \ Initialize nucleus objects - fFcb, fEvent, fpRect, fWind
" fpInit" sFind IF drop cfa execute THEN \ Initialize FP system
0 ?event drop abs: fWind call BeginUpdate
getVrect: fWind 14 + put: tempRect update: tempRect
abs: fWind call EndUpdate
initNewWindow: fwind show: fwind
<[ 2 ]> 'cfas enfW disfW setAct: fWind \ fWind activate activities
OpenNR
new: imageName new: parmStr
nPath
nMenu \ get Yerk menu bar
initProcs \ loads all proc words with a5,a3
myDoc 2dup put: imageName title: fWind \ fWind title bar
?yerkFlgs release ;
'c yerk -> objInit